﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Biz.Process
{
    public class Cmd2011Sqls
    {
        //主
        public static string M_EXIST = "SELECT COUNT(1) FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[主实时数据_企业ID]') AND type IN('U')";
        public static string M_CREATE = "CREATE TABLE [主实时数据_企业ID] ([ID] int  IDENTITY(1,1) NOT NULL,[企业排口ID] int  NOT NULL,[监测时间] datetime  NOT NULL,[污染物类别ID] int  NOT NULL,[RTD] float(53)  NOT NULL,[累计量] decimal(18)  NOT NULL)";
        public static string M_ALTER_1 = "ALTER TABLE [主实时数据_企业ID] SET (LOCK_ESCALATION = TABLE)";
        public static string M_ALTER_2 = "ALTER TABLE [主实时数据_企业ID] ADD CONSTRAINT [PK_主实时数据_企业ID] PRIMARY KEY CLUSTERED ([ID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]";
        public static string M_NONCLUSTERED_1 = "CREATE NONCLUSTERED INDEX [IDX_主实时数据_企业ID_企业排口ID] ON [主实时数据_企业ID] ([企业排口ID] ASC)";
        public static string M_NONCLUSTERED_2 = "CREATE NONCLUSTERED INDEX [IDX_主实时数据_企业ID_污染物类别ID] ON [主实时数据_企业ID] ([污染物类别ID] ASC)";
        public static string M_NONCLUSTERED_3 = "CREATE NONCLUSTERED INDEX [IDX_主实时数据_企业ID_监测时间] ON [主实时数据_企业ID] ([监测时间] DESC)";

        public static string M_UPDATE = "UPDATE [主实时数据_企业ID] SET [企业排口ID] = {企业排口ID},[监测时间] = {监测时间},[污染物类别ID] = {污染物类别ID},[RTD] = {RTD},[累计量] = {累计量} WHERE {搜索条件}";
        public static string M_INSERT = "INSERT INTO [主实时数据_企业ID]([企业排口ID],[监测时间],[污染物类别ID],[RTD],[累计量])VALUES({企业排口ID},{监测时间},{污染物类别ID},{RTD},{累计量})";
        public static string M_SELECT = "SELECT COUNT(1) FROM [主实时数据_企业ID] WHERE {搜索条件} ";
        //从
        public static string D_EXIST = "SELECT COUNT(1) FROM sys.all_objects WHERE object_id = OBJECT_ID(N'[dbo].[从实时数据_企业ID]') AND type IN ('U')";
        public static string D_CREATE = "CREATE TABLE [从实时数据_企业ID] ([ID] int  IDENTITY(1,1) NOT NULL,[主实时数据ID] int  NOT NULL,[污染物编码ID] int  NOT NULL,[RTD] float(53)  NOT NULL,[ZSRTD] float(53)  NULL,[Flag] nvarchar(3) COLLATE Chinese_PRC_CI_AS  NULL)";
        public static string D_ALTER_1 = "ALTER TABLE [从实时数据_企业ID] SET (LOCK_ESCALATION = TABLE)";
        public static string D_ALTER_2 = "ALTER TABLE [从实时数据_企业ID] ADD CONSTRAINT [PK_从实时数据_企业ID] PRIMARY KEY CLUSTERED ([ID]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]";
        public static string D_NONCLUSTERED_1 = "CREATE NONCLUSTERED INDEX [IDX_从实时数据_企业ID_主数据ID] ON [dbo].[从实时数据_企业ID] ([主实时数据ID] ASC)";
        public static string D_NONCLUSTERED_2 = "CREATE NONCLUSTERED INDEX [IDX_从实时数据_企业ID_污染物编码ID] ON [dbo].[从实时数据_企业ID] ([污染物编码ID] ASC)";

        public static string D_UPDATE = "UPDATE [从实时数据_企业ID] SET [主实时数据ID] = {主实时数据ID},[污染物编码ID] = {污染物编码ID},[RTD] = {RTD},[ZSRTD] ={ZSRTD},[Flag] = {Flag} WHERE {搜索条件}";
        public static string D_INSERT = "INSERT INTO [从实时数据_企业ID]([主实时数据ID],[污染物编码ID],[RTD],[ZSRTD],[Flag])VALUES({主实时数据ID},{污染物编码ID},{RTD},{ZSRTD},{Flag})";
        public static string D_SELECT = "SELECT COUNT(1) FROM [从实时数据_企业ID] WHERE {搜索条件} ";



    }
}
